home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / owldlgs.zip / DLGNOPAR.CPP < prev    next >
C/C++ Source or Header  |  1993-04-08  |  3KB  |  67 lines

  1. /**********************************************************************/
  2. /*                  Dlgnopar.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 12/16/91                */
  4. /*              This program demonstrates a dialog box                */
  5. /*       with a menu and two buttons that can call a non-modal        */
  6. /*    dialog box with out a parent from either the menu or a button   */
  7. /*      A non-modal dialog box will not keep control.  You can go     */
  8. /*      to other windows while it is open.  A non-modal dialog box    */
  9. /*      without a parent becomes its own main window dialog box.      */
  10. /*    If another window gets the focus, a non-modal without a parent  */
  11. /*             will go behind the window with the focus.              */
  12. /**********************************************************************/
  13. #include <owl.h>
  14. #include <dialog.h>
  15. #include "dlgnopar.h"
  16.  
  17. class TDialog6Dialog : public TDialog    // Dialog class to add
  18.   {                     // processing for menu and
  19.   public:                 // button selections
  20.     TDialog6Dialog(LPSTR lpName)         // constructor calls
  21.       :TDialog(NULL,lpName) {};         // base class constructor
  22.     virtual void HandleMenuItem(RTMessage Msg)      // menu handler
  23.       = [CM_FIRST + IDM_NON_MODAL_DIALOG];
  24.     virtual void HandleButtonMessage(RTMessage Msg) // button handler
  25.       = [ID_FIRST + IDB_NON_MODAL_DIALOG];   // close button handled by
  26.   };                                     // base class button handler
  27. void TDialog6Dialog:: HandleMenuItem(RTMessage)
  28.   {
  29.   GetApplication()->MakeWindow(new TDialog(NULL,"Non_Modal_Dialog_Box"));
  30.   }               // MakeWindow activates a non-modal dialog box
  31.           // the null qualifier makes it parentless.
  32. void TDialog6Dialog:: HandleButtonMessage(RTMessage)
  33.   {
  34.   GetApplication()->MakeWindow(new TDialog(NULL,"Non_Modal_Dialog_Box"));
  35.   }
  36.  
  37. class TDialog6App : public TApplication  // Application Class to contain
  38.   {                                      // the application
  39.   public:
  40.     TDialog6App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  41.         HANDLE hPrevInstance,            // base class constructor
  42.         LPSTR lpCmdLine, int nCmdShow)
  43.         :TApplication(lpName, hInstance,
  44.                   hPrevInstance,
  45.                   lpCmdLine, nCmdShow) {};
  46.  
  47.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  48.   };
  49.  
  50. void TDialog6App::InitMainWindow() // to initialize a dialog box
  51.   {                                // as the main window
  52.   MainWindow = new TDialog6Dialog("Main_Window_Dialog");
  53.   }                                // using message processing provided
  54.                    // by derived class
  55.  
  56. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  57.            HANDLE hPrevInstance,          // windows to this program
  58.            LPSTR lpCmdLine , int nCmdShow)
  59.   {
  60.   TDialog6App Dialog6("Dialog Tester",hInstance,  // create instance of
  61.                hPrevInstance,             // the dialog application
  62.                lpCmdLine,nCmdShow);
  63.   Dialog6.Run();                                  // run it
  64.   return (Dialog6.Status);                        // exit
  65.   }
  66. /**********************************************************************/
  67.